<template>
    <div class="product-family">
        <div class="ge-product-family-hero">
            <div class="ge-product-family-hero-grid">
                <el-row class="row-bg" justify="space-between">
                    <el-col :span="18" class="hidden-xs-only">
                        <h2 class="product-family-slider__title">Our Products By Category</h2>
                    </el-col>
                    <el-col :span="6" class="hidden-xs-only">
                        <div class="ge-product-family-hero-button-wrapper flex-end">
                            <div class="slick-prev" :class="currentSwiper === 0 ? 'slick-disabled' : ''" @click="slickPrev">
                                <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="32"
                                    height="32" viewBox="0 0 32 32">
                                    <g id="Caret_Left_-_32" data-name="Caret Left - 32">
                                        <path
                                            d="M21,30a1,1,0,0,1-.71-.29l-13-13a1,1,0,0,1,0-1.42l13-13a1,1,0,1,1,1.42,1.42L9.41,16l12.3,12.29a1,1,0,0,1,0,1.42A1,1,0,0,1,21,30Z">
                                        </path>
                                    </g>
                                </svg>
                            </div>
                            <div class="slick-next" :class="currentSwiper === swiperData.length - 1 ? 'slick-disabled' : ''"
                                @click="slickNext">
                                <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="32"
                                    height="32" viewBox="0 0 32 32">
                                    <g id="Caret_Right_-_32" data-name="Caret Right - 32">
                                        <path
                                            d="M11,30a1,1,0,0,1-.71-.29,1,1,0,0,1,0-1.42L22.59,16,10.29,3.71a1,1,0,0,1,1.42-1.42l13,13a1,1,0,0,1,0,1.42l-13,13A1,1,0,0,1,11,30Z">
                                        </path>
                                    </g>
                                </svg>
                            </div>
                        </div>
                    </el-col>
                    <el-col :span="24" class="hidden-sm-and-up">
                        <h2 class="product-family-slider__title">Our Products By Category</h2>
                    </el-col>
                </el-row>
            </div>
            <div class="ge-product-family-hero__wrapper">
                <div class="slick-prev hidden-sm-and-up" :class="currentSwiper === 0 ? 'slick-disabled' : ''" @click="slickPrev">
                    <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="32" height="32"
                        viewBox="0 0 32 32">
                        <g id="Caret_Left_-_32" data-name="Caret Left - 32">
                            <path
                                d="M21,30a1,1,0,0,1-.71-.29l-13-13a1,1,0,0,1,0-1.42l13-13a1,1,0,1,1,1.42,1.42L9.41,16l12.3,12.29a1,1,0,0,1,0,1.42A1,1,0,0,1,21,30Z">
                            </path>
                        </g>
                    </svg>
                </div>
                <div class="slick-next hidden-sm-and-up" :class="currentSwiper === swiperData.length - 1 ? 'slick-disabled' : ''"
                    @click="slickNext">
                    <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="32" height="32"
                        viewBox="0 0 32 32">
                        <g id="Caret_Right_-_32" data-name="Caret Right - 32">
                            <path
                                d="M11,30a1,1,0,0,1-.71-.29,1,1,0,0,1,0-1.42L22.59,16,10.29,3.71a1,1,0,0,1,1.42-1.42l13,13a1,1,0,0,1,0,1.42l-13,13A1,1,0,0,1,11,30Z">
                            </path>
                        </g>
                    </svg>
                </div>
                <div class="swiper-slide-wrap">
                    <div ref="swiperSlide" class="swiper-slide" :style="{ left: '-' + swiperX + 'px' }">
                        <div v-for="item of swiperData" :key="'slide' + item.id" class="swiper-slide-item">
                            <div class="ge-product-family-content-item">
                                <a class="ge-product-family-content-item__link" target>
                                    <el-image fit="cover" :src="item.img"
                                        style="width: 100%;height: 100%;overflow: auto;"></el-image>
                                </a>
                            </div>
                            <p class="ge-product-family-content-item__title ptag">{{ item.title }}</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref } from 'vue';
let swiperData = ref([
    {
        id: '1',
        url: 'https://www.gehealthcare.com/products/imaging',
        img: new URL(`@/assets/home/gehc_hp_pf01_imaging_dtm.webp`, import.meta.url).href,
        title: 'Imaging'
    },
    {
        id: '2',
        url: 'https://www.gehealthcare.com/products/ultrasound',
        img: new URL(`@/assets/home/ultrasound.avif`, import.meta.url).href,
        title: 'Ultrasound'
    },
    {
        id: '3',
        url: 'https://www.gehealthcare.com/products/healthcare-it',
        img: new URL(`@/assets/home/healthcare-it.avif`, import.meta.url).href,
        title: 'Healthcare IT'
    },
    {
        id: '4',
        url: 'https://www.gehealthcare.com/products/contrast-media',
        img: new URL(`@/assets/home/gehc_hp_pf04_pia_dtm.webp`, import.meta.url).href,
        title: 'Contrast Media'
    },
    {
        id: '5',
        url: 'https://www.gehealthcare.com/products/anesthesia-delivery',
        img: new URL(`@/assets/home/anesthesia-delivery-systems.avif`, import.meta.url).href,
        title: 'Anesthesia Delivery Systems'
    },
    {
        id: '6',
        url: 'https://www.gehealthcare.com/products/diagnostic-ecg',
        img: new URL(`@/assets/home/gehc_hp_pf07_diagnosticecg_dtm.webp`, import.meta.url).href,
        title: 'Diagnostic ECG'
    },
    {
        id: '7',
        url: 'https://www.gehealthcare.com/products/maternal-infant-care',
        img: new URL(`@/assets/home/gehc_hp_pf08_maternalinfantcare_dtm.webp`, import.meta.url).href,
        title: 'Products & Resources for Maternal Infant Care '
    },
    {
        id: '8',
        url: 'https://www.gehealthcare.com/products/patient-monitoring',
        img: new URL(`@/assets/home/patient-monitoring-solutions.avif`, import.meta.url).href,
        title: 'Patient Monitoring Solutions'
    },
    {
        id: '9',
        url: 'https://www.gehealthcare.com/products/ventilators',
        img: new URL(`@/assets/home/gehc_hp_pf10_ventilator_dtm.webp`, import.meta.url).href,
        title: 'Ventilators'
    }
])
let currentSwiper = ref(0)
let swiperX = ref(0)
let swiperSlide = ref()
function slickPrev() {
    if (currentSwiper.value > 0) {
        currentSwiper.value = currentSwiper.value - 1
        swiperX.value = currentSwiper.value * (swiperSlide.value.clientWidth / swiperData.value.length)
    }
}
function slickNext() {
    if (currentSwiper.value < swiperData.value.length - 1) {
        currentSwiper.value = currentSwiper.value + 1
        swiperX.value = currentSwiper.value * (swiperSlide.value.clientWidth / swiperData.value.length)
    }
}
</script>
<style lang="scss" scoped>
.product-family {
    box-sizing: border-box;

    .ge-product-family-hero {
        padding-top: 48px;
        padding-bottom: 48px;
        background-color: #fbf9fd;
        overflow: hidden;
        position: relative;

        .ge-product-family-hero-grid {
            padding-top: 0;
            padding-bottom: 0;
        }
    }
}

.product-family-slider__title {
    color: #222222;
    margin-top: 0;
    margin-bottom: 0;
    font-size: 1.5rem;
    line-height: 2rem;
    letter-spacing: -.75px;
    font-weight: 400;
}

.ge-product-family-hero-button-wrapper {}

.flex-end {
    display: flex;
    justify-content: flex-end;
}

.slick-prev,
.slick-next {
    font-size: 22px;
    width: 40px;
    height: 40px;
    background-color: #6022a6;
    border-radius: 50%;
    text-align: center;
    cursor: pointer;

    &:hover {
        background-color: #411771;
    }
}

.slick-next {
    margin-left: 24px;
}

.slick-disabled {
    background-color: #f4f1f8 !important;

    &:hover {
        background-color: #f4f1f8 !important;
    }
}

.slick-next svg,
.slick-prev svg {
    width: 22px;
    height: 22px;
    vertical-align: middle;
    fill: #ffffff;
}

.ge-product-family-hero__wrapper {
    box-sizing: border-box;
    margin: 0 auto;
    padding-top: 10px;
    max-width: 1280px;
    height: 400px;
    box-sizing: border-box;
    position: relative;
    .slick-prev{
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        left: 10px;
        z-index: 10000;
    }
    .slick-next{
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        right: 10px;
        z-index: 10000;
    }
}


.swiper-slide-wrap {
    position: relative;
    left: 0;
    top: 0;
    height: 100%;
}

.swiper-slide {
    position: absolute;
    left: 0;
    display: flex;
    transition: 1s;
    margin-left: 24px;
}

.swiper-slide-item {
    margin-right: 24px;
}

.ge-product-family-content-item {
    vertical-align: top;
    color: #222222;
    min-width: 246px !important;
    height: 100%;
    position: relative;
    transition: all 1s ease;
    background-color: #ffffff;

    &:hover {
        box-shadow: 0 10px 15px rgba(22, 41, 65, .15);

        .ge-product-family-content-item-border {
            opacity: 1;
        }
    }
}

.ge-product-family-content-item__link {
    display: block;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    border-radius: 8px;
    overflow: hidden;

    &:hover {
        border: 2px solid var(--interaction);
    }
}

.ge-product-family-content-item__title {
    margin: 16px 0 0;
    color: #222222;
    font-size: 1rem;
    line-height: 25px;
    letter-spacing: 0;
    font-weight: 400;
}

.ge-product-family-hero-grid {
    box-sizing: border-box;
    margin: 0 auto;
    padding: 24px;
    max-width: 1280px;
}

@media (min-width: 720px) {
    .ge-product-family-hero__wrapper {
        height: 300px;
    }

    .ge-product-family-content-item {
        height: 255px;
        width: 255px;
    }
}

@media (min-width: 320px) and (max-width: 720px) {
    .ge-product-family-hero__wrapper {
        height: 260px;
    }

    .ge-product-family-content-item {
        height: 246px;
        width: 246px;
    }
}

@media (min-width: 960px) {
    .ge-product-family-hero__wrapper {
        height: 420px;
    }

    .ge-product-family-hero-grid {
        margin-bottom: 38px;
        box-sizing: border-box;
        margin: 0 auto;
    }

    .product-family-slider__title {
        font-size: 2.5rem;
        line-height: 3rem;
        letter-spacing: -1.25px;
    }

    .ge-product-family-content-item {
        height: 336px;
        width: 336px;
    }

    .ge-product-family-content-item__title {
        font-size: 1.1rem;
        line-height: 30px;
    }
}
</style>